<template>
    <div class="navbar-container">
        <div v-if="$slots.left">
            <!-- 具名插槽 -->
            <slot name="left">left</slot>
        </div>
        <div v-if="$slots.default" style="text-align: center;">
            <!-- 默认插槽 -->
            <slot name="default" />
        </div>
        <!-- 具名插槽 -->
        <div v-if="$slots.right">
            <slot name="right">right</slot>
        </div>
    </div>
</template>

<script setup>
import { useSlots, ref } from 'vue'
const msg = ref('子子子')
// 获取父组件传递来的插槽信息
const slots = useSlots()
console.log(slots.left)

</script>

<style lang="scss" scoped>
.navbar-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 4px;
    height: 54px;
    background-color: #ccc;
}
</style>